<template>
	<view class="uni-padding-wrap uni-common-pb">
		
		<view class="uni-card" v-for="(list,index) in lists" :key="index">
			<view class="uni-list">
				<view class="uni-list-cell uni-collapse">
					<view class="uni-list-cell-navigate uni-navigate-bottom" hover-class="uni-list-cell-hover" :class="list.open ? 'uni-active' : ''"
					 @click="triggerCollapse(index)">
						<view class="">{{list.name}}</view>
						<view style="color: #929292;position: relative;right: 30upx;">{{list.tag}}</view>
					</view>
					<view class="uni-list uni-collapse" :class="list.open ? 'uni-active' : ''">
						<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key) in list.pages" :key="key" @click="goDetailPage(item)">
							<view class="uni-list-cell-navigate uni-navigate-right"> 
								<view>
									{{item.name}}
								</view>
								<view style="color: #929292;position: relative;right: 30upx;">
									{{item.tag}}
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				lists: [{
						id: 'view',
						name: '刑法',
						open: false,
						tag:"0/100",
						pages: [{name:'vasd',tag:'0/10'},{name:'vasd',tag:'0/10'},{name:'vasd',tag:'0/10'},{name:'vasd',tag:'0/10'},{name:'vasd',tag:'0/10'}
						]
					}, {
						id: 'content',
						name: '刑法诉讼法',
						open: false,
						pages: ['text', 'rich-text', 'progress']
					}, {
						id: 'form',
						name: '刑法诉讼',
						open: false,
						pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio',
							'slider',
							'switch',
							'textarea',
							'editor',
						]
					}, {
						id: 'nav',
						name: '法理',
						open: false,
						pages: ['navigator']
					}, {
						id: 'media',
						name: '阿斯蒂芬',
						open: false,
						pages: [
							'image',
							'video',
							'audio',
						],
					},
					{
						id: 'map',
						name: '微软',
						open: false,
						pages: ['map']

					},
					{
						id: 'web-view',
						name: '网页',
						open: false,
						pages: [{
							name: '网络网页',
							url: '/pages/component/web-view/web-view'
						}, {
							name: '本地网页',
							url: '/pages/component/web-view-local/web-view-local'
						}]
					},
					{
						id: 'web-view',
						name: '网页',
						open: false,
						pages: ['web-view']
					},
				]
			}
		},
		onShareAppMessage() {
			return {
				title: '欢迎体验uni-app',
				path: '/pages/tabBar/component/component'
			}
		},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url: '/pages/about/about'
			});
		},
		methods: {
			triggerCollapse(e) {
				if (!this.lists[e].pages) {
					this.goDetailPage(this.lists[e].url);
					return;
				}
				for (var i = 0; i < this.lists.length; ++i) {
					if (e === i) {
						this.lists[i].open = !this.lists[e].open;
					} else {
						this.lists[i].open = false;
					}
				}
			},
			goDetailPage(e) {
				// if (typeof e === 'string') {
				// 	uni.navigateTo({
				// 		url: '/pages/component/' + e + '/' + e
				// 	})
				// } else {
				// 	uni.navigateTo({
				// 		url: e.url
				// 	})
				// }
				
				uni.navigateTo({
					url:'/pages/objectiveShorthand/detail'
				})
			}
		}
	}
</script>

<style>
	@import url("../../common/uni/uni.css");
	page {
		background-color: #F4F5F6;
		height: 100%;
		font-size: 28upx;
		line-height: 1.8;
	}
	
	.uni-header-logo {
		padding: 30upx;
		text-align: center;
		margin-top: 10upx;
	}
	
	.uni-header-logo image {
		width: 140upx;
		height: 140upx;
	}
	
	.uni-hello-text {
		color: #7A7E83;
	}
	
	.uni-hello-addfile {
		text-align: center;
		line-height: 300upx;
		background: #FFF;
		padding: 50upx;
		margin-top: 10px;
		font-size: 38upx;
		color: #808080;
	}
	page {
		height: auto;
		min-height: 100%;
	}

	.uni-card {
		box-shadow: none;
	}

	.uni-list:after {
		height: 0;
	}

	.uni-list:before {
		height: 0;
	}
</style>
